<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>个人信息</title>
<meta name="viewport" content="width=100%, initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/lib/weix/style/weui.min.css">
<link rel="stylesheet" href="/css/fonts.css">
<link rel="stylesheet" href="/css/comm.css">
</head>

<body>
<div class="weui-cells">    
    <a class="weui-cell weui-cell_access no_jt" href="javascript:;">
        <div class="weui-cell__bd">
            <p>微信头像</p>
        </div>
        <div class="weui-cell__ft" style="width:50px; height:50px;">
			<img src="/images/motoux.png" class="user__toux_img" style="width:100%; height:100%; object-fit:cover; border-radius:3px;" id="J_pic" />
        </div>
    </a>
    <a class="weui-cell weui-cell_access no_jt" href="javascript:;">
        <div class="weui-cell__bd">
            <p>姓名</p>
        </div>
        <div class="weui-cell__ft" id="J_customer"></div>
    </a>
    <a class="weui-cell weui-cell_access no_jt J_cell_no" href="tel:13600008888" id="J_phone_tel">
        <div class="weui-cell__bd">
            <p>手机</p>
        </div>
        <div class="weui-cell__ft" style="color:#007df1" id="J_phone"></div>
    </a>
    <a class="weui-cell weui-cell_access J_cell_no" href="/userPage/edit/${id}">
        <div class="weui-cell__bd">
            <p>类型</p>
        </div>
        <div class="weui-cell__ft" id="J_roleName"></div>
    </a>
    <a class="weui-cell weui-cell_access J_cell_no" href="/userPage/edit/${id}" id="J_group_box">
        <div class="weui-cell__bd">
            <p>分组</p>
        </div>
        <div class="weui-cell__ft" id="J_group"></div>
    </a>
    <a class="weui-cell weui-cell_access no_jt" href="javascript:;">
        <div class="weui-cell__bd">
            <p>添加人</p>
        </div>
        <div class="weui-cell__ft" id="J_addName"></div>
    </a>
    <a class="weui-cell weui-cell_access J_cell_show" href="javascript:;" style="display:none;">
        <div class="weui-cell__bd">
            <p>客户记录</p>
        </div>
        <div class="weui-cell__ft">
        </div>
    </a>
</div>

<div class="weui-cells" id="J_band" style="display:none;">
    <a class="weui-cell weui-cell_access" href="/userPage/adduser?topen=2&id=${id}">
        <div class="weui-cell__bd">
            <p>绑定登录</p>
        </div>
        <div class="weui-cell__ft">
        	<i class="icon-code" style="vertical-align:0"></i>
        </div>
    </a>
</div>

<div class="weui-btn-area" id="J_clo_box" style="display:none;">
    <a class="weui-btn weui-btn_warn" href="javascript:" id="J_clo">移除</a>
</div>

<script src="/js/zepto.min.js"></script>
<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
<script src="/js/comm.js"></script>
<script type="text/javascript">
$(function(){
	//返回本页刷新
	//window.addEventListener("pageshow", function(){
//		if(sessionStorage.getItem("need-refresh")){
//			location.reload();
//			sessionStorage.removeItem("need-refresh");
//		}
//	});

	var myself_data = GetQueryString('myself')	//是否自己查看 0代表自己查看
	
	if(myself_data != 0){
		$('#J_clo_box').show();					//控制删除按钮
	}
	//-------------------------------------------------------------------
	//数据
	var id  = "${id}";
    var data = {id:id};
    var url = "/user/getUserDeail";
    $.ajax({
        type: "POST",
        async: false,
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(data),
        url: url,
        success: function(res){
            //console.log(res);
            if(res.code == 200){
                var datas = res.data;

				if(datas.avatar != null){
					$('#J_pic').attr('src',datas.avatar);
					$('#J_band').remove()
				}else{
					$('#J_band').show()
				}
				
				$('#J_customer').html(datas.name);
                $('#J_phone').html(datas.phone);
				$('#J_phone_tel').attr('href','tel:'+datas.phone+'');
                $("#J_roleName").html(datas.roleName);
                
				
				if(datas.pid == 2){		//pid 2员工 3合伙人
					if(datas.groupName != null){
						$('#J_group').html(datas.groupName)
					}else{
						$('#J_group').html('未分组');
					}
					
				}else{
					$('#J_group_box').hide()
				}
				
				$('#J_addName').html(datas.addName);
                $('#J_points').html(datas.points);
				
				
				
				//console.log('id='+id+'-------------------------------id2='+datas.id)
				
				$('.J_cell_no').addClass('no_jt').attr('href','javascript:;"') 					//去掉箭头和跳转
				
				//if(id == datas.id){																	//如果是自己
//					$('#J_phone').css('color','#999')												//电话颜色
//					$('.J_cell_no').addClass('no_jt').attr('href','javascript:;"') 					//去掉箭头和跳转
//					$('.J_cell_clo').remove()														//删除
//				}else{
//					$('.J_cell_show').show();														//客户记录
//				}
				
            }else{
				weui.topTips(res.msg);
            }
        },
        error: function(){
        },
        complete: function(){
        }
    });
	
	//---------------------------------------------------------------------
	//移除
	$(document).on('click','#J_clo',function(){
		weui.dialog({
			title: '移除用户',
			content: '确认移除该用户？',
			className: 'custom-classname',
			buttons: [{
				label: '取消',
				type: 'default',
				onClick: function () {}
			}, {
				label: '确定',
				type: 'primary',
				onClick: function () {
					
					var loading = weui.loading('数据提交中', {
						className: 'custom-classname'
					});

					var data = {id:id}
					$.ajax({
						type: "POST",
						async: false,
						dataType: 'json',
						contentType: "application/json; charset=utf-8",
						data: JSON.stringify(data),
						url: '/user/delete_user',
						success: function(res){
							if(res.code == 10001){
								weui.toast('删除成功', {
									duration: 1500,
									className: 'custom-classname',
									callback: function(){ 
										history.back(-1)
									}
								});
							}else{
								weui.topTips(res.msg);
							}
						},
						error: function(){
						},
						complete: function(){
							loading.hide();
						}
					});

					 
				}
			}]
		});

	})
	
});
</script>
</body>
</html>